package com.qiaofang.constant;

import com.qiaofang.common.utils.StringUtil;

public enum ConfirmStatusEnum {

    PAYDEPOSIT_FAILD("A", "认筹失败", null),
    SUBSCRIBE_FAILD("B", "退定", null),
    SIGN_FAILD("C", "退房", null),
    confirm("0", "待定", null),
    payDeposit("1", "认筹", 4005),
    subscribe("2", "认购", 4006),
    sign("3", "签约", 4007),
    sign_fail("4", "失败", 4008);

    private final String no;

    private final String des;

    private final Integer apiAction;

    ConfirmStatusEnum(String no, String des, Integer apiAction) {
        this.no = no;
        this.des = des;
        this.apiAction = apiAction;
    }

    public String getNo() {
        return no;
    }

    public String getDes() {
        return des;
    }

    public Integer getApiAction() {
        return apiAction;
    }

    public static ConfirmStatusEnum getByNo(String no) {
        if (StringUtil.isBlank(no)) {
            return null;
        }
        for (ConfirmStatusEnum value : values()) {
            if (value.getNo().equals(no)) {
                return value;
            }
        }
        return null;
    }

    public static ConfirmStatusEnum getByDesc(String desc) {
        if (StringUtil.isBlank(desc)) {
            return null;
        }
        for (ConfirmStatusEnum value : values()) {
            if (value.getDes().equals(desc)) {
                return value;
            }
        }
        return null;
    }

    public static String getDescByNo(String no) {
        return getByNo(no) == null ? "" : getByNo(no).getDes();
    }

}
